var CustomerReport = {

};

/**
 * 查看客户产品报表
 */
CustomerReport.search = function () {
    var customer = $("#customer").val();
    if($.trim(customer) == ''){
        Feng.info("请输入客户名称！");
        return ;
    }

    var ajax = new $ax(Feng.ctxPath + "/customer/getCustomerByName", function (data) {
        var queryData = {};
        queryData['customer'] = $("#customer").val();
        FxReport.table.refresh({query: queryData});
        FxTotalReport.table.refresh({query: queryData});
        OptionReport.table.refresh({query: queryData});
    },function (data) {
        Feng.info(customer+"客户不存在！");
        return ;
    });

    ajax.set("userName", customer);
    ajax.start();

}

CustomerReport.send = function (){
    var customer = $("#customer").val();
    if($.trim(customer) == ''){
        Feng.info("请输入客户名称！");
        return ;
    }
    var ajax = new $ax(Feng.ctxPath + "/customerReport/sendMail", function (data) {
        if(data.code == 200)
            Feng.success("发送邮件成功!");
        else
            Feng.error("发送邮件失败!" + data.message + "!");
    },function (data){
        Feng.error("发送邮件失败!" + data.responseJSON.message + "!");
    });
    ajax.set("customer", customer);
    ajax.start();
}


$(function () {
    //
    var fxReportColumns = FxReport.initColumn();
    var fxReportTable = new BSTable(FxReport.id, "/customerReport/fxReport", fxReportColumns);
    fxReportTable.height = 300;
    fxReportTable.pagination = false;
    fxReportTable.setPaginationType("client");
    FxReport.table = fxReportTable.init();

    var fxTotalReportColumns = FxTotalReport.initColumn();
    var fxTotalReportTable = new BSTable(FxTotalReport.id, "/customerReport/fxTotalReport", fxTotalReportColumns);
    fxTotalReportTable.height = 300;
    fxTotalReportTable.pagination = false;
    fxTotalReportTable.setPaginationType("client");
    FxTotalReport.table = fxTotalReportTable.init();

    var optionReportColumns = OptionReport.initColumn();
    var optionReportTable = new BSTable(OptionReport.id, "/customerReport/optionReport", optionReportColumns);
    optionReportTable.height = 600;
    optionReportTable.pagination = false;
    optionReportTable.setPaginationType("client");
    OptionReport.table = optionReportTable.init();
});